/**
 * Copyright (C), 2015-2019, XXX有限公司
 * FileName: SmsCodeGenerator
 * Author:   zhouheng
 * Date:     2019/6/10 23:41
 * Description:
 * History:
 * <author>          <time>          <version>          <desc>
 * 作者姓名           修改时间           版本号              描述
 */
package com.zhouh.golden.security.code.sms;

import com.zhouh.golden.security.code.ValidateCode;
import com.zhouh.golden.security.code.ValidateCodeGenerator;
import com.zhouh.golden.security.properties.GoldenSecurityProperties;
import org.apache.commons.lang3.RandomStringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 〈一句话功能简述〉<br> 
 * 〈〉
 *
 * @author zhouheng
 * @create 2019/6/10
 * @since 1.0.0
 */
@Component(value = "smsCodeGenerator")
public class SmsCodeGenerator implements ValidateCodeGenerator {

    @Autowired
    private GoldenSecurityProperties securityProperties;
    
    /**
     * @description: 发送短信
     * @date: 2019/6/10 23:43
     * @author:zhouheng
     */
    @Override
    public ValidateCode createCode() {
        String code = RandomStringUtils.randomNumeric(securityProperties.getCode().getSms().getLength());
        return new ValidateCode(code, securityProperties.getCode().getSms().getExpireIn());
    }
}